import { post, get, postFormData } from "../api";
// import qs from "qs"; // 根据需求是否导入qs模块(用来序列化post类型的数据)

const profile = {
    //获取用户信息
    getUserInfoApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/getUserInfo", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //用户头像修改
    updateUserIconApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/updateUserIcon", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //用户信息修改
    updateUserInfoApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/updateUserInfo", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //修改密码--校验老密码
    changePwdVerifyApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/changePwdVerify", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //修改密码--保存
    changePwdSaveApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/changePwdSave", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //更换邮箱-校验密码
    changEmailVerifyApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/changEmailVerify", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
    //更换邮箱-保存
    changeEmailSaveApi(params) {
        return new Promise((resolve, reject) => {
            post("/metamemory/user/changeEmailSave", params)
                .then((res) => {
                    resolve(res.data);
                })
                .catch((err) => {
                    reject(err.data);
                });
        });
    },
}

export default profile 